import { DnFC } from '@inbiz/react';
import { createBehavior, createResource } from '@inbiz/core';
import PreviewBIPieChartProps from '../../preview/web';
import Locale from '../locale';
import { Schema, defaultProps } from './schema';

const BIPieChart: DnFC<React.ComponentProps<typeof PreviewBIPieChartProps>> =
  PreviewBIPieChartProps;

BIPieChart.Behavior = createBehavior({
  name: 'BIPieChart',
  extends: ['Field'],
  selector: (node) => node?.props?.['x-component'] === 'BIPieChart',
  designerLocales: Locale,
  designerProps: Schema,
});

BIPieChart.Resource = createResource({
  icon: 'Pie',
  elements: [
    {
      componentName: 'Field',
      props: {
        title: {
          status: true,
          value: 'BIPieChart.title',
        },
        type: 'string',
        'x-decorator': 'Container',
        'x-component': 'BIPieChart',
        'x-component-props': defaultProps,
      },
    },
  ],
});

export default BIPieChart;
